package com.deyang.mycommon.ui.activity.study;

import android.os.Build;
import android.os.Bundle;
import android.support.annotation.RequiresApi;
import android.view.Gravity;
import android.widget.ImageView;
import android.widget.LinearLayout;

import com.deyang.mycommon.R;
import com.deyang.mycommon.ui.baseui.BaseActivity;
import com.deyang.mycommon.util.DensityUtil;

import butterknife.BindView;
import butterknife.ButterKnife;

public class ViewPaddingActivity extends BaseActivity {


    @BindView(R.id.ll_content)
    LinearLayout llContent;

    @Override
    protected void initView(Bundle savedInstanceState) {
        setContentView(R.layout.activity_view_padding);
        ButterKnife.bind(this);
    }

    @RequiresApi(api = Build.VERSION_CODES.JELLY_BEAN)
    @Override
    protected void processLogic(Bundle savedInstanceState) {

        LinearLayout linearLayout = new LinearLayout(this);
        linearLayout.setBackgroundColor(getColorRes(R.color.web_load_blue));
        linearLayout.setOrientation(LinearLayout.VERTICAL);
        linearLayout.setGravity(Gravity.CENTER);
        LinearLayout.LayoutParams params = new LinearLayout.LayoutParams(DensityUtil.dip2px(this, 40), DensityUtil.dip2px(this, 40));
        params.gravity = Gravity.CENTER;
        linearLayout.setLayoutParams(params);

        ImageView imgLeft = new ImageView(this);
        imgLeft.setBackground(getResources().getDrawable(R.drawable.jian));
        //左图ImgageView设置ID，便于使用addRule时通过ID定位
        LinearLayout.LayoutParams leftImgParams = new LinearLayout.LayoutParams(DensityUtil.dip2px(this, 20), DensityUtil.dip2px(this, 20));
        imgLeft.setLayoutParams(leftImgParams);
        linearLayout.addView(imgLeft);

        llContent.addView(linearLayout);
    }

}
